package com.eflow.model.domain;

import cn.hutool.core.util.StrUtil;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

/**
 * @CLASSNAME EflowUser
 * @Description
 * @Auther JanHezz
 * @BLOG www.luckyhe.com
 * @DATE 2021/3/8 10:29
 */
@Data
public class EflowUser implements Serializable,Comparable<EflowUser>{

    private String userId;
    private String userName;

    private String proxyUserId;
    private String proxyUserName;
    private String proxyNickName;
    private boolean proxy;

    private String nickName;

    private String deptId;
    private String deptName;
    private String proxyDeptId;
    private String proxyDeptName;

    private String groupCode;
    private String groupName;


    private String tenantId;

    private Double sort;


    /**
     * 用户只需要比较userId就为同一个用户
     * @param o
     * @return
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        EflowUser that = (EflowUser) o;
        return Objects.equals(userId, that.userId) ;
    }

    @Override
    public int hashCode() {
        return Objects.hash(userId);
    }

    @Override
    public int compareTo(EflowUser o) {
        return this.getSort().compareTo(o.getSort());
    }

    public String getName(){
        return proxy? StrUtil.format("{}({})",proxyNickName,nickName) :nickName;
    }
}
